//package com.xls.aclservice.service.impl;
//
//import com.xls.aclservice.entity.SysMenu;
//import com.xls.aclservice.entity.SysUser;
//import com.xls.aclservice.mapper.SysMenuMapper;
//import com.xls.aclservice.service.SysUserService;
//import com.xls.base.exception.BusinessException;
//import com.xls.entity.SecurityUser;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Service
//public class UserDetailServiceImpl implements UserDetailsService {
//
//    @Autowired
//    private SysUserService sysUserService;
//
//    @Autowired
//    private SysMenuMapper sysMenuMapper;
//
//    @Override
//    public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
//        //SysUser sysUser = sysUserService.selectByUsername(name);
//        //if (sysUser == null) {
//        //    throw new BusinessException(999, "用户名或密码错误");
//        //} else if (!sysUser.getStatus()) {
//        //    throw new BusinessException(999, "用户被禁用");
//        //}
//        //List<SysMenu> sysMenus = sysMenuMapper.getMenusById(sysUser.getId());
//        //List<String> collect = sysMenus.stream().map(SysMenu::getPermissionValue).collect(Collectors.toList());
//        //List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
//        //for (String authority : collect) {
//        //    if (!("").equals(authority) && authority != null) {
//        //        GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(authority);
//        //        grantedAuthorities.add(grantedAuthority);
//        //    }
//        //}
//        //com.xls.entity.User curUser = new com.xls.entity.User();
//        //BeanUtils.copyProperties(sysUser,curUser);
//        //SecurityUser securityUser = new SecurityUser(curUser, grantedAuthorities);
//        //return securityUser;
//        return new SecurityUser();
//    }
//}
